package com.qin.mall.controller.ordercontroller;

import com.qin.mall.common.api.CommonResult;
import com.qin.mall.common.api.MyBatisPlusPage;
import com.qin.mall.domain.OmsOrderReturnApply;
import com.qin.mall.dto.OmsReturnApplyQueryParam;
import com.qin.mall.dto.OmsUpdateStatusParam;
import com.qin.mall.openfeign.order.OmsOrderReturnApplyFeigin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单退货申请管理
 * @author Leisure
 * create 2022 2022/11/22 11:26
 **/
@RestController
@RequestMapping("/returnApply")
public class OrderReturnApplyController {
    
    @Autowired
    private OmsOrderReturnApplyFeigin orderReturnApplyFeigin;

    /**
     * 分页条件查询申请
     */
    @GetMapping("/list")
    @ResponseBody
    public CommonResult<MyBatisPlusPage<OmsOrderReturnApply>> list(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
                                                                   @RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize,
                                                                   OmsReturnApplyQueryParam queryParam){
        CommonResult<MyBatisPlusPage<OmsOrderReturnApply>> list = orderReturnApplyFeigin.list(pageNum, pageSize, queryParam);
        return list;
    }

    /**
     * 获取指定申请详情
     */
    @GetMapping("/{id}")
    public CommonResult getItem(@PathVariable Long id){
        CommonResult item = orderReturnApplyFeigin.getItem(id);
        return item;
    }

    /**
     * 批量删除申请
     */
    @PostMapping("/delete")
    public CommonResult delete(@RequestParam("ids") List<Long> ids){
        CommonResult delete = orderReturnApplyFeigin.delete(ids);
        return delete;
    }

    /**
     * 修改申请状态
     */
    @PostMapping("/update/status/{id}")
    @ResponseBody
    public CommonResult updateStatus(@PathVariable Long id,
                                     @RequestBody OmsUpdateStatusParam statusParam){
        CommonResult result = orderReturnApplyFeigin.updateStatus(id, statusParam);
        return result;
    }
}
